package com.sc.VenusQueryBeta.presenter.hotel.tabs;

import com.hengjun.kingstar.sdk.utils.LogUtils;
import com.sc.VenusQueryBeta.contract.hotel.tabs.HotelDiningContract;
import com.sc.VenusQueryBeta.model.bean.home.HotelRestaurantBean;
import com.sc.VenusQueryBeta.model.hotel.tabs.HotelDiningModel;

import io.reactivex.functions.Consumer;

/**
 * 酒店餐厅Presenter
 */

public class HotelDiningPresenter extends HotelDiningContract.HotelDiningPresenter {
    @Override
    protected HotelDiningContract.IHotelDiningModel getModel() {
        return HotelDiningModel.newInstance();
    }

    /**
     * 实例化对象
     */
    public static HotelDiningPresenter newInstance(){
        return new HotelDiningPresenter();
    }
    @Override
    public void onStart() {

    }

    @Override
    public void loadLatestList() {

    }

    @Override
    public void loadMoreList() {

    }

    @Override
    public void onItemClick(int position, Object item) {

    }

    @Override
    public void getHotelRestaurantData(int vipClubId) {
        mRxManager.register(mIModel.getHotelRestaurant(vipClubId).subscribe(new Consumer<HotelRestaurantBean>() {

            @Override
            public void accept(HotelRestaurantBean hotelRestaurantBean) throws Exception {
                if (mIView != null)
                    mIView.showHotelRestaurantDataSuccess(hotelRestaurantBean);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                LogUtils.e("error="+throwable.getLocalizedMessage());
                if (mIView != null) {
//                    if (mIView.isVisiable())
//                        mIView.showToast("Network error.");
                    mIView.showNetworkError();
                }
            }
        }));
    }
}
